package sw6.visualschedule.entities;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import java.util.Date;

@DatabaseTable(tableName = "activityscheduledates")
public class DbDate {

    public static final String ACTIVITY_ID_FIELD = "activity_id";
    public static final String DATE_FIELD = "date";
    
    @DatabaseField(columnName = ACTIVITY_ID_FIELD, foreign = true)
    private transient ScheduleActivity mActivity;
    
    @DatabaseField(columnName = DATE_FIELD, canBeNull = false)
    private transient Date mDate;
    
    @DatabaseField(generatedId = true)
    private transient Integer mId;
    
    public DbDate(final ScheduleActivity act, final Date date) {
        mActivity = act;
        mDate = date;        
    }
    
    DbDate() {
        // all persisted classes must define a no-arg constructor with at least package visibility
    }
    
    public ScheduleActivity getActivity() {
        return mActivity;
    }
    
    public Date getDate() {
        return mDate;
    }
    
    public Integer getId() {
        return mId;
    }
    
    public void setDate(final Date date) {
    	mDate = date;
    }
    
    @Override
    public String toString() {
        return java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM, java.text.DateFormat.SHORT).format(mDate).toString();
    }
}
